Add field separator to "pretty_deg_format".
authoroliskoli <oliskoli>
Thu, 28 Jun 2007 22:12:45 +0000 (22:12 +0000)
committeroliskoli <oliskoli>
Thu, 28 Jun 2007 22:12:45 +0000 (22:12 +0000)
defs.h
garmin_gpi.c
html.c
text.c
util.c

diff --git a/defs.h b/defs.h
index 92057a607be9b6cff8ebda1da7a873f3350a5877..1dffa3e8f9d89d2ee0127d00fa217ef662e5e2b4 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -770,7 +770,7 @@ char * strip_html(const utf_string*);
 char * strip_nastyhtml(const char * in);
 char * convert_human_date_format(const char *human_datef);     /* "MM,YYYY,DD" -> "%m,%Y,%d" */
 char * convert_human_time_format(const char *human_timef);     /* "HH+mm+ss"   -> "%H+%M+%S" */
-char * pretty_deg_format(double lat, double lon, char fmt, int html);   /* decimal ->  dd.dddd or dd mm.mmm or dd mm ss */
+char * pretty_deg_format(double lat, double lon, char fmt, char *sep, int html);   /* decimal ->  dd.dddd or dd mm.mmm or dd mm ss */
 
 char * get_filename(const char *fname);                                /* extract the filename portion */
 
index 3d36c816cbc055de64af96bb1d246c2757b2b335..cdd6d4aae10267510f3c16cee168dad787635a3a 100644 (file)
@@ -640,7 +640,7 @@ wdata_compute_size(writer_data_t *data)
                                str = xstrdup(wpt->notes);
                }
                else if (opt_pos)
-                       str = pretty_deg_format(wpt->latitude, wpt->longitude, 's', 0);
+                       str = pretty_deg_format(wpt->latitude, wpt->longitude, 's', " ", 0);
                        
                if (str) {      /* this will be stored into street-address field */
                        res += 22 + strlen(str);
diff --git a/html.c b/html.c
index fa4abb7b84f977ffb126587d2807df0b8625f0f4..3b2ac13290a7831058aa468ebd642ffe0e82a9c9 100644 (file)
--- a/html.c
+++ b/html.c
@@ -89,7 +89,7 @@ html_disp(const waypoint *wpt)
        gbfprintf(file_out, "\n<a name=\"%s\"><hr></a>\n", wpt->shortname);
        gbfprintf(file_out, "<table width=\"100%%\">\n");
        gbfprintf(file_out, "<tr><td><p class=\"gpsbabelwaypoint\">%s - ",(global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname);
-       cout = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], 1);
+       cout = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 1);
        gbfprintf(file_out, "%s (%d%c %6.0f %7.0f)", cout, utmz, utmzc, utme, utmn);
        xfree (cout);
        if (wpt->altitude != unknown_alt)
@@ -199,7 +199,7 @@ html_disp(const waypoint *wpt)
                                if ( coordstr ) {
                                        lon = atof( coordstr );
                                }
-                               coordstr = pretty_deg_format(lat, lon, degformat[2], 1);
+                               coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 1);
                                gbfprintf( file_out,
                                        "<span class=\"gpsbabellogcoords\">%s</span><br>\n",
                                        coordstr );
diff --git a/text.c b/text.c
index 5bf59ae3f8d25c109c7edd08506112ccd3117f9f..a8a3a2efa4c4ac4d348cb54f36b11f0837a6aa3f 100644 (file)
--- a/text.c
+++ b/text.c
@@ -91,7 +91,7 @@ text_disp(const waypoint *wpt)
                tm = time(NULL);
        strftime(tbuf, sizeof(tbuf), "%d-%b-%Y", localtime(&tm));
 
-       tmpout1 = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], 0);
+       tmpout1 = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 0);
        if (wpt->altitude != unknown_alt) {
                xasprintf(&altout, " alt:%d", (int) ( (altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude) );
        }
@@ -193,7 +193,7 @@ text_disp(const waypoint *wpt)
                                if ( coordstr ) {
                                        lon = atof( coordstr );
                                }
-                               coordstr = pretty_deg_format(lat, lon, degformat[2], 0);
+                               coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 0);
                                gbfprintf( file_out, "%s\n", coordstr);
                                xfree(coordstr);
                        }
diff --git a/util.c b/util.c
index 225fe65fad3814fe097e8f283a5c5e72b461ccb2..82630846368eb8c719295da52035565a16d39f5b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1394,10 +1394,11 @@ convert_human_time_format(const char *human_timef)
  * Return a decimal degree pair as
  * DD.DDDDD  DD MM.MMM or DD MM SS.S
  * fmt = ['d', 'm', 's']
+ * sep = string between lat and lon (separator)
  * html = 1 for html output otherwise text
  */
 char *
-pretty_deg_format(double lat, double lon, char fmt, int html) 
+pretty_deg_format(double lat, double lon, char fmt, char *sep, int html) 
 {
        double  latmin, lonmin, latsec, lonsec;
        int     latint, lonint;
@@ -1411,19 +1412,20 @@ pretty_deg_format(double lat, double lon, char fmt, int html)
        lonmin = 60.0 * (fabs(lon) - lonint);
        latsec = 60.0 * (latmin - floor(latmin));
        lonsec = 60.0 * (lonmin - floor(lonmin));
+       if (sep == NULL) sep = " ";     /* default " " */
        if (fmt == 'd') { /* ddd */
-               xasprintf ( &result, "%c%6.5f%s %c%6.5f%s",
-                       latsig, fabs(lat), html?"&deg;":"", 
+               xasprintf ( &result, "%c%6.5f%s%s%c%6.5f%s",
+                       latsig, fabs(lat), html?"&deg;":"", sep,
                        lonsig, fabs(lon), html?"&deg;":"" );
        }
        else if (fmt == 's') { /* dms */
-               xasprintf ( &result, "%c%d%s%02d'%04.1f\" %c%d%s%02d'%04.1f\"",
-                        latsig, latint, html?"&deg;":" ", (int)latmin, latsec,
+               xasprintf ( &result, "%c%d%s%02d'%04.1f\"%s%c%d%s%02d'%04.1f\"",
+                        latsig, latint, html?"&deg;":" ", (int)latmin, latsec, sep,
                        lonsig, lonint, html?"&deg;":" ", (int)lonmin, lonsec);
        }
        else { /* default dmm */
-               xasprintf ( &result,  "%c%d%s%06.3f %c%d%s%06.3f",
-                       latsig, latint, html?"&deg;":" ", latmin, 
+               xasprintf ( &result,  "%c%d%s%06.3f%s%c%d%s%06.3f",
+                       latsig, latint, html?"&deg;":" ", latmin, sep,
                        lonsig, lonint, html?"&deg;":" ", lonmin);
        } 
        return result;